import { PuppeteerButton } from "./PuppeteerButton";
import { PuppeteerInput } from "./PuppeteerInput";
import * as puppeteer from 'puppeteer'
import { PuppeteerListen } from "./PuppeteerListen";

export class LJPuppeteer {

    static Browser: puppeteer.Browser;
    static Page: puppeteer.Page;

    async createPage(url: string, BrowserLaunchOpts: puppeteer.LaunchOptions = {
        executablePath: "src/chromium/chrome.exe",
        headless: false,
        args: ['--start-maximized'],
        defaultViewport: {
            width: 1920,
            height: 860,
        },
    }) {
        LJPuppeteer.Browser = await puppeteer.launch(BrowserLaunchOpts);
        LJPuppeteer.Page = await LJPuppeteer.Browser.newPage();
        await LJPuppeteer.Page.goto(url);
    }

    createButton() {
        return new PuppeteerButton(LJPuppeteer.Page);
    };

    createInput() {
        return new PuppeteerInput(LJPuppeteer.Page);
    };

    createListen() {
        return new PuppeteerListen(LJPuppeteer.Page);
    }
    async closeBrowser() {
        await LJPuppeteer.Browser.close();
    }
}
export class LaunchOpt implements puppeteer.LaunchOptions {
    executablePath: string;
    headless: boolean;
}